package com.fy.fyspace.model.enums.user;

import lombok.Getter;

@Getter
public enum UserStatusEnum {
    IS_NORMAL(0, "账号正常"),
    IS_DELETE(1, "账号禁用");

    private final Integer status;
    private final String desc;

    UserStatusEnum(Integer status, String desc) {
        this.status = status;
        this.desc = desc;
    }

    public static UserStatusEnum getEnumByStatus(Integer status) {
        if (status == null) {
            throw new IllegalArgumentException("Status cannot be null");
        }
        for (UserStatusEnum statusEnum : UserStatusEnum.values()) {
            if (statusEnum.getStatus().equals(status)) {
                return statusEnum;
            }
        }
        throw new IllegalArgumentException("Invalid status: " + status);
    }

    public static UserStatusEnum getEnumByDesc(String desc) {
        if (desc == null) {
            throw new IllegalArgumentException("Description cannot be null");
        }
        for (UserStatusEnum statusEnum : UserStatusEnum.values()) {
            if (statusEnum.getDesc().equals(desc)) {
                return statusEnum;
            }
        }
        throw new IllegalArgumentException("Invalid description: " + desc);
    }
}
